from machine import Pin

buttonPin = Pin(23, Pin.IN, Pin.PULL_UP)


def pressed_button(pin):
    print("按钮被按下了")


def released_button(pin):
    print("按钮被释放了")


# 从高到底
buttonPin.irq(trigger=Pin.IRQ_FALLING, handler=pressed_button)
# 从低到高
buttonPin.irq(trigger=Pin.IRQ_RISING, handler=released_button)

while True:
    pass
